<template>
  <div>
    <h1>登录页</h1>
    <input v-model="username" placeholder="用户名" />
    <input v-model="password" placeholder="密码" type="password" />
    <button @click="login">登录</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    };
  },
  methods: {
    login() {
      if (this.username === 'admin') {
        sessionStorage.setItem('userRole', 'admin');
      } else {
        sessionStorage.setItem('userRole','student');
      }
      this.$router.push('/');
    }
  }
};
</script>